/**
 * File Created at 2016年4月27日
 * Copyright 2016 汉威.智慧环保事业部 Limited.
 * All rights reserved.
 */
package com.hw.one.collect.resource;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Primary;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 获取spring 容器管理的bean
 * @author duqunxing
 *
 */
@Component
public class BaseContext implements ApplicationContextAware{

    private static ApplicationContext applicationContext;
    @SuppressWarnings("static-access")
	@Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public synchronized static Object getService(String serviceName) {
        return applicationContext.getBean(serviceName);
    }
}
